package org.siam.impl.data.formatting {
	
	import mx.core.IFactory;
	import mx.formatters.Formatter;
	
	import org.siam.core.data.formatting.IFormattingManager;
	import org.siam.core.data.formatting.IFormattingManagerFactory;
	import org.siam.impl.common.RegistryFactory;
	import org.siam.impl.common.XMLFactory;

	public class FormattingManagerFactory extends XMLFactory implements IFormattingManagerFactory {
		
		public function FormattingManagerFactory(input:XML) {
			super(input);
		}
		
		public function newInstance():IFormattingManager {
			var instance:FormattingManager = new FormattingManager();
			if (input) {
				new RegistryFactory(input, Formatter, "formatter",
					function(id:String):Boolean {
						return instance.hasFormatter(id);
					},
					function(id:String, factory:IFactory):void {
						instance.registerFormatter(id, factory.newInstance()); 
					}).parseInput();
			}
			return instance;
		}
	}
}